<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link rel="stylesheet" type="text/css" href="{$app:qlib}/ui.css" media="all">
<script src="{$app:qlib}/Q.js">
<!--
import utils.json2;
import utils.ajax;
import ui.select;
-->
</script>
<link rel="stylesheet" type="text/css" href="{$themes:path}/plugin_wayixia.css" media="all">

<style>
<!--
#left {
      height: 272px;
	  background: #FFF;
	  text-align:left;
	  padding-left:30px;
	  border:3px solid #b6cddc;
}


-->
</style>

<script>
<!--

var login_error = {};
login_error[-1] = '重复登录';
login_error[-2] = '用户名或密码为空';
login_error[-3] = '用户不存在或者密码错误';

function ajax_login() {
  // 处理用户登录
  var username = Q.$('login-name').value;
  var userpwd = Q.$('login-pwd').value;

  Q.Ajax({
    command: '{$app:app}&mod=user&action=do-login&inajax=true',
    data: {name: username, pwd: userpwd },
    oncomplete : function(xmlhttp) {
      // console.log(xmlhttp.responseText);
      var resp = eval('('+xmlhttp.responseText+')');
      if(resp && resp.header == 0) {
        // 登录成功
		//Q.$('login-area').style.display = 'none';
		
		// 保存key
        //g_client_key = resp.data;
		history.back();
	  } else {
		var err = login_error[resp.header];
		if(err) {
		  alert('登录失败!('+err+')');
		} else {
		  alert('登录失败!(未知错误)');
		}

		Q.$('button-ok').disabled= false;
	  }
	}
  });
}

Q.Ready(function() {

	Q.$('button-ok').onclick = function() {
		var _this = this;
		_this.disabled = true;
		ajax_login();
	}

	Q.$('button-cancel').onclick = function() {
	   window.close();	
	}

	Q.$('login-forgetpwd').href='{$app:app}&mod=user&action=forgetpwd';
	Q.$('login-forgetpwd').target = '_blank';
	Q.$('login-register').href='{$app:app}&mod=user&action=register';
	Q.$('login-register').target = '_blank';

});

//-->
</script>
</head>
<body style="background:#CFDFEF;margin:0;padding:0;height:100%;">

<div id="wa-panel" style="margin:auto; padding: 10px; border:1px solid #CCC;">
	<div style="clear:both; height:35px; line-height:35px;text-indent: 0px;color: #000;">
	<h3 style="margin: 0px; color:#4d6a7c;" id="wayixia_title"> 
		亲！您还没有登录哦：
	</h3>
	</div>
	<div id="left">
		<br><br>
		用户名:<br><input type="text" id="login-name"/>
		<br><br>密码:<br>
		<input type="password" id="login-pwd"/>
		<br/>
		(<a href="#" target="_blank" id="login-forgetpwd">忘记密码</a> 
		| <a href="#" target="_blank" id="login-register">注册</a>)

<br><br><br>
		<p align="left">
			<button id="button-cancel" style="width: 100px; height: 30px;"> No, 放弃 </button>
			<button id="button-ok" style="width: 100px; height: 30px;"> Ok，登录 </button>
		</p>
	</div>
</div>

</body>
</html>
